<template>
    <div class="news-wrap">
        <div class="news-tab">
            <div class="item"
                 :class="{active: v.id === search.tYPE}"
                 v-for="v in news.tab.list"
                 :key="v.id"
                 @click="handlerTab(v.id)">
                <div class="text">{{v.name}}</div>
            </div>
        </div>
        <div class="news-list">
            <router-link class="item" :to="'/news/' + v.id + '?type=' + search.tYPE" v-for="v in list" :key="v.id">
                <l-image class="img"
                         mode="cover"
                         width="200"
                         height="150"
                         :src="v.photo"></l-image>
                <div class="info">
                    <div class="name">{{v.name || v.aname | lineClamp(20)}}</div>
                    <div class="desc">{{v.content || v.field | htmlTagEmpty | lineClamp(35)}}</div>
                    <div class="suit">
                        <div><i class="iconfont icon-calendar"></i>{{v.createdTime | dateFormat}}</div>
                        <div>&emsp;&emsp;</div>
                        <div><i class="iconfont icon-see"></i>{{v.count || 0}}次</div>
                    </div>
                </div>
            </router-link>
            <div class="list-loading">{{page.lastPage ? '没有了' : '加载中'}}</div>
        </div>
        <ipx-block></ipx-block>
    </div>
</template>

<script>
    import list from '@m/mixins/list'

    export default {
        name: 'NewsList',
        mixins: [list],
        data() {
            return {
                news: {
                    tab: {
                        active: '类型1',
                        list: [
                            {
                                name: '类型1',
                                id: 0,
                            },
                            {
                                name: '类型2',
                                id: 1,
                            },
                            {
                                name: '类型3',
                                id: 2,
                            },
                        ]
                    }
                },
                search: {
                    tYPE: 0
                },
                api: this.$api.news.list
            }
        },
        computed: {},
        async created() {
        },
        async mounted() {
            this.handlerTab(0)
        },
        methods: {
            handlerTab(v) {
                this.search.tYPE = v
                this.page.page = 1
                this.handlerSearch()
            },
            async getHot() {
                this.handlerSearch()
            }
        }
    }
</script>

<style lang="scss">
    @import "./style";
</style>
